package infos

import (
	"github.com/gin-gonic/gin"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/app/ginsrv/oplog"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core"
)

// Init 初始化
func Init(route *gin.RouterGroup, d core.CmsDomain) {
	info := createInfoCtrl(d)
	route.GET("infos", info.getInfoPageList)
	route.GET("infos/:infoid", info.getInfo)

	route.GET("search", info.getSchPageList)
	// 获取指定栏目的信息
	route.GET("columns/:columnid", info.getColumn)
	route.GET("columns/:columnid/infos", info.getColumnInfoList)
	route.GET("groups", info.getGroups)
	route.GET("groups/:groupid/infos", info.getGroupInfoList)
	// 指定显示方式
	route.GET("groups/:groupid", info.getGroup)
	route.GET("groupinfos", info.getGroupInfos)

	route.GET("adapter/columns/:columnid/infos/:show", info.getColumnInfoList)
	route.GET("adapter/groups/:groupid/infos/:show", info.getGroupInfoList)
	route.GET("adapter/groups4key/:flags/infos/:show", info.getGroupInfoList4Key)
	route.GET("adapter/infos/:show", info.getInfoPageList)
	route.GET("adapter/myinfos/:show", info.getMyInfoPageList)

	route.POST("infos", oplog.OplogRoute("api新增信息", "cms/api/infos/add", info.addInfo))

	route.GET("myinfos", info.getMyInfoPageList)

	route.PUT("infos/:infoid", oplog.OplogRoute("api修改信息", "cms/api/infos/update", info.updateInfoDesc))
	route.PUT("infos/:infoid/publish", oplog.OplogRoute("api发布信息", "cms/api/infos/publish", info.publish))
	route.PUT("infos/:infoid/unpublish", oplog.OplogRoute("api取消发布信息", "cms/api/infos/unpublish", info.unpublish))
	route.DELETE("infos/:infoid", oplog.OplogRoute("api删除信息", "cms/api/infos/delete", info.deleteInfo))
	route.PUT("infos/:infoid/extral", oplog.OplogRoute("api修改指定的扩展属性", "cms/api/infos/update/extral", info.updateInfoExtral))

	route.GET("parks/:parkid", info.getParks)
	route.GET("parks/:parkid/carouse", info.getParksCarouse)
	route.GET("enterprises/:enterid", info.getEnterprises)
	route.GET("enterprises/:enterid/carouse", info.getEnterprisesCarouse)

	route.POST("feedback", oplog.OplogRoute("api新增建议反馈", "cms/api/feedback/add", info.postFeedBack))
}
